<?php
declare(strict_types=1);
namespace app\index\controller;
use think\facade\Db;
use think\facade\View;

class Goods
{
    //查询
    public function index()
    {
        // [Db查询]
        // 条件查询
        // $cha = Db::table('ecm_goods')->where('goods_id','=',1)->find();
        // 主键ID查询
        // $cha = Db::name('goods')->find(1);
        // 原生查询
        // $cha = Db::query("select * from ecm_goods where goods_id = 1");
        // select():查询结果为数据集对象 调用->toArray() 转成数组格式;
        $cha = Db::name('goods')->where('goods_id','<','5')->select();//->toArray()

        View::assign('cha',$cha);
        return View::fetch();


    }
}